/*     */ package com.newcrm.db;
/*     */ 
/*     */ import com.newcrm.exception.DBException;
/*     */ import java.sql.Connection;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.dbutils.DbUtils;
/*     */ import org.apache.commons.dbutils.MyMapHandler;
/*     */ import org.apache.commons.dbutils.QueryRunner;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class UserEmailManager
/*     */ {
/*  16 */   private static Logger logger = Logger.getLogger(UserEmailManager.class
/*  17 */     .getName());
/*     */ 
/*     */   public int add(String id, String host, int port, String userName, String userPwd, boolean isSSL, String emailAddress, String sign)
/*     */     throws SQLException, DBException
/*     */   {
/*  37 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  38 */     if (conn == null) {
/*  39 */       throw new DBException();
/*     */     }
/*  41 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/*  44 */       return runner.update(conn, "INSERT INTO T_User_Email (UserId,Host,Port,UserName,UserPwd,IsSSL,EmailAddress,EmailSign,CreateDate,UpdateDate) VALUES (?,?,?,?,?,?,?,?,NOW(),NOW())", new Object[] { id, host, 
/*  45 */         Integer.valueOf(port), userName, userPwd, Integer.valueOf(isSSL ? 1 : 0), emailAddress, sign });
/*     */     } finally {
/*     */       try {
/*  48 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  50 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public int update(String id, String host, int port, String userName, String userPwd, boolean isSSL, String emailAddress, String sign)
/*     */     throws SQLException, DBException
/*     */   {
/*  73 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  74 */     if (conn == null) {
/*  75 */       throw new DBException();
/*     */     }
/*  77 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/*  80 */       return runner.update(conn, "UPDATE T_User_Email SET Host = ?, Port = ?, UserName = ?, UserPwd = ?, IsSSL = ?, EmailAddress = ?, EmailSign = ?, UpdateDate = NOW() WHERE UserId = ?", new Object[] { host, Integer.valueOf(port), 
/*  81 */         userName, userPwd, Integer.valueOf(isSSL ? 1 : 0), emailAddress, sign, id });
/*     */     } finally {
/*     */       try {
/*  84 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  86 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public Map<String, Object> getUserEmailSetting(String userId)
/*     */     throws DBException, SQLException
/*     */   {
/* 101 */     Connection conn = ConnectionManager.getInstance().getConnection();
/* 102 */     if (conn == null) {
/* 103 */       throw new DBException();
/*     */     }
/*     */ 
/* 106 */     QueryRunner runner = new QueryRunner();
/*     */     try {
/* 108 */       return (Map)runner.query(conn, "SELECT * FROM T_User_Email WHERE UserId = ?", 
/* 109 */         new MyMapHandler(), new Object[] { userId });
/*     */     } finally {
/*     */       try {
/* 112 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/* 114 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.db.UserEmailManager
 * JD-Core Version:    0.6.1
 */